Skip to contentSkip to conversation

Change in openvpn[master]: tun.c: don't attempt to delete DNS and WINS servers if they're not set

Openvpn-devel In review stipa (Code Review) 3 participants 13 messages Dec 14, 2023 – Dec 21, 2023 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1702561084000.I21a36d24f8e213c780f55acbe3e4df555c93542a@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/482?usp=email

to review the following change.

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

tun.c: don't attempt to delete DNS and WINS servers if they're not set

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

---
M src/openvpn/tun.c

1 file changed, 13 insertions(+), 23 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/1

src/openvpn/tun.c +13 -23
index f1b8699..9104d46 100644
@@ -147,17 +147,16 @@
     return ret;
 }
 
-static bool
+static void
 do_dns_domain_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
 
     if (!tt->options.domain) /* no  domain to add or delete */
     {
-        return true;
+        goto out;
     }
 
     /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
     }
 
     msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_dns_service(bool add, const short family, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,11 @@
     int addr_len = add ? len : 0;
     const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (((family == AF_INET6) && (tt->options.dns6_len == 0))
+        || ((family == AF_INET) && (tt->options.dns_len == 0)))
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +270,23 @@
     }
 
     msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_wins_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
-    int len = tt->options.wins_len;
-    int addr_len = add ? len : 0;
+    int addr_len = add ? tt->options.wins_len : 0;
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (tt->options.wins_len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     wins_cfg_message_t wins = {
@@ -338,11 +333,9 @@
     }
 
     msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
 static bool
@@ -7019,10 +7012,7 @@
             {
                 do_dns_domain_service(false, tt);
             }
-            if (tt->options.dns6_len > 0)
-            {
-                do_dns_service(false, AF_INET6, tt);
-            }
+            do_dns_service(false, AF_INET6, tt);
             delete_route_connected_v6_net(tt);
             do_address_service(false, AF_INET6, tt);
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 1:

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/4c9d6f7d_e58ded94 :
PS1, Line 19: However, due to bug we always attempted to remove DNS/WINS,
What's the issue with always trying to remove these? Is there an error message in the log or something else? Probably should be mention here if we have such a reason for this patch

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Sat, 16 Dec 2023 10:13:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 1:

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/d7d9f828_cf70f1a1 :
PS1, Line 19: However, due to bug we always attempted to remove DNS/WINS,

Quoted 1 line

What's the issue with always trying to remove these? Is there an error message in the log or somethi […]

Why delete something that we haven't added? We have this logic (do not delete if not added) for DNS6 already. Besides, in some cases it might take up to 3 seconds.

2023-12-14 07:45:35 Closing DCO interface
2023-12-14 07:45:35 delete_route_ipv6(fd00:abcd:194:1::/64)
2023-12-14 07:45:35 IPv6 route deletion via service succeeded
2023-12-14 07:45:35 INET6 address service: remove fd00:abcd:194:1::1005/128
2023-12-14 07:45:38 WINS servers deleted using service

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 07:53:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 1:

(1 comment)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/bcb4535d_4ecbfd8b :
PS1, Line 19: However, due to bug we always attempted to remove DNS/WINS,

Quoted 1 line

Why delete something that we haven't added? We have this logic (do not delete if not added) for DNS6 […]

Such a delay is the good reason I was looking for. Maybe could be added in a sentence to the commit message.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 11:09:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: d12fk <[email protected]...>
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos, stipa.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 1: Code-Review-1

(2 comments)

Patchset:

PS1:
Generally looks correct.

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/ce967642_7be70959 :
PS1, Line 212: if (((family == AF_INET6) && (tt->options.dns6_len == 0))
can be shortened to "len == 0"

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 14:37:10 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos, stipa.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/482?usp=email

to look at the new patch set (#2).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

tun.c: don't attempt to delete DNS and WINS servers if they're not set

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds.

This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

---
M src/openvpn/tun.c

1 file changed, 12 insertions(+), 23 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/2

src/openvpn/tun.c +12 -23
index f1b8699..8e96149 100644
@@ -147,17 +147,16 @@
     return ret;
 }
 
-static bool
+static void
 do_dns_domain_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
 
     if (!tt->options.domain) /* no  domain to add or delete */
     {
-        return true;
+        goto out;
     }
 
     /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
     }
 
     msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_dns_service(bool add, const short family, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,10 @@
     int addr_len = add ? len : 0;
     const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +269,23 @@
     }
 
     msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_wins_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
-    int len = tt->options.wins_len;
-    int addr_len = add ? len : 0;
+    int addr_len = add ? tt->options.wins_len : 0;
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (tt->options.wins_len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     wins_cfg_message_t wins = {
@@ -338,11 +332,9 @@
     }
 
     msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
 static bool
@@ -7019,10 +7011,7 @@
             {
                 do_dns_domain_service(false, tt);
             }
-            if (tt->options.dns6_len > 0)
-            {
-                do_dns_service(false, AF_INET6, tt);
-            }
+            do_dns_service(false, AF_INET6, tt);
             delete_route_connected_v6_net(tt);
             do_address_service(false, AF_INET6, tt);
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset

#7 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, flichtenheld, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 2:

(2 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/6bccb548_434b4cc2 :
PS1, Line 19: However, due to bug we always attempted to remove DNS/WINS,

Quoted 1 line

Such a delay is the good reason I was looking for. […]

Done

File src/openvpn/tun.c:

http://gerrit.openvpn.net/c/openvpn/+/482/comment/60defa74_6e621889 :
PS1, Line 212: if (((family == AF_INET6) && (tt->options.dns6_len == 0))

Quoted 1 line

can be shortened to "len == 0"

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Mon, 18 Dec 2023 15:18:31 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment

#8 lore raw
In reply to a message not in the archive

Attention is currently required from: d12fk, plaisthos, stipa.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 20 Dec 2023 13:36:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#9 lore raw

PATCH v2 1/1 tun.c: don't attempt to delete DNS and WINS servers if they're not set

In reply to a message not in the archive

From: Lev Stipakov <[email protected]...>

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds.

This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/482
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/tun.c +12 -23
index f1b8699..8e96149 100644
@@ -147,17 +147,16 @@
     return ret;
 }
 
-static bool
+static void
 do_dns_domain_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
 
     if (!tt->options.domain) /* no  domain to add or delete */
     {
-        return true;
+        goto out;
     }
 
     /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
     }
 
     msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_dns_service(bool add, const short family, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,10 @@
     int addr_len = add ? len : 0;
     const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +269,23 @@
     }
 
     msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_wins_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
-    int len = tt->options.wins_len;
-    int addr_len = add ? len : 0;
+    int addr_len = add ? tt->options.wins_len : 0;
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (tt->options.wins_len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     wins_cfg_message_t wins = {
@@ -338,11 +332,9 @@
     }
 
     msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
 static bool
@@ -7019,10 +7011,7 @@
             {
                 do_dns_domain_service(false, tt);
             }
-            if (tt->options.dns6_len > 0)
-            {
-                do_dns_service(false, AF_INET6, tt);
-            }
+            do_dns_service(false, AF_INET6, tt);
             delete_route_connected_v6_net(tt);
             do_address_service(false, AF_INET6, tt);
         }
#10 lore raw

Re: [Openvpn-devel] [PATCH v2] tun.c: don't attempt to delete DNS and WINS servers if they're not set

Quoted 21 lines · Frank Lichtenheld

From: Lev Stipakov <[email protected]...>

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds.

This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Quoted 7 lines
Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Should also be merged to release/2.6

Regards,

Signature · 1 line
  Frank Lichtenheld
#11 lore raw

[Openvpn-devel] [PATCH applied] Re: tun.c: don't attempt to delete DNS and WINS servers if they're not set

In reply to Frank Lichtenheld

Have only test compiled... but stare-at-code looks quite reasonable.

Nice catch on the possible gc_arena leak in do_dns_domain_service().

Your patch has been applied to the master and release/2.6 branch (bugfix).

commit c590868a721881dd21bfb77ecf846e6c8720e4ef (master) commit 030afe64198e6c32297dcdbf33ff9c5f6a35f5e1 (release/2.6)

Author: Lev Stipakov
Date:   Wed Dec 20 14:36:37 2023 +0100
     tun.c: don't attempt to delete DNS and WINS servers if they're not set

     Signed-off-by: Lev Stipakov <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg27843.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#12 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

tun.c: don't attempt to delete DNS and WINS servers if they're not set

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds.

This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27843.html

---
M src/openvpn/tun.c

1 file changed, 12 insertions(+), 23 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/82/482/3

src/openvpn/tun.c +12 -23
index f1b8699..8e96149 100644
@@ -147,17 +147,16 @@
     return ret;
 }
 
-static bool
+static void
 do_dns_domain_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
 
     if (!tt->options.domain) /* no  domain to add or delete */
     {
-        return true;
+        goto out;
     }
 
     /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
     }
 
     msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_dns_service(bool add, const short family, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,10 @@
     int addr_len = add ? len : 0;
     const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +269,23 @@
     }
 
     msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_wins_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
-    int len = tt->options.wins_len;
-    int addr_len = add ? len : 0;
+    int addr_len = add ? tt->options.wins_len : 0;
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (tt->options.wins_len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     wins_cfg_message_t wins = {
@@ -338,11 +332,9 @@
     }
 
     msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
 static bool
@@ -7019,10 +7011,7 @@
             {
                 do_dns_domain_service(false, tt);
             }
-            if (tt->options.dns6_len > 0)
-            {
-                do_dns_service(false, AF_INET6, tt);
-            }
+            do_dns_service(false, AF_INET6, tt);
             delete_route_connected_v6_net(tt);
             do_address_service(false, AF_INET6, tt);
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#13 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/482?usp=email )

Change subject: tun.c: don't attempt to delete DNS and WINS servers if they're not set
......................................................................

tun.c: don't attempt to delete DNS and WINS servers if they're not set

Commits

1c4a47f7 ("wintun: set adapter properties via interactive service") 18826de5 ("Set WINS servers via interactice service")

added functionality of add/remove DNS/WINS via interactive service, which is used mostly by dco-win and wintun (tap-windows6 normally uses DHCP). There is a check in code - if DNS/WINS addresses are not pushed, nothing is added.

However, due to bug we always attempted to remove DNS/WINS, even if nothing was added. Removing WINS, for example, could take up to 3 seconds.

This change fixes this by improving check "has DNS/WINS been pushed?".

While on it, convert do_XXX_service() functions to "void" from "bool", since we never check their return values.

Change-Id I21a36d24f8e213c780f55acbe3e4df555c93542a

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27843.html

---
M src/openvpn/tun.c

1 file changed, 12 insertions(+), 23 deletions(-)
src/openvpn/tun.c +12 -23
index f1b8699..8e96149 100644
@@ -147,17 +147,16 @@
     return ret;
 }
 
-static bool
+static void
 do_dns_domain_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
 
     if (!tt->options.domain) /* no  domain to add or delete */
     {
-        return true;
+        goto out;
     }
 
     /* Use dns_cfg_msg with addr_len = 0 for setting only the DOMAIN */
@@ -195,17 +194,14 @@
     }
 
     msg(M_INFO, "DNS domain %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_dns_service(bool add, const short family, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
@@ -213,9 +209,10 @@
     int addr_len = add ? len : 0;
     const char *ip_proto_name = family == AF_INET6 ? "IPv6" : "IPv4";
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     /* Use dns_cfg_msg with domain = "" for setting only the DNS servers */
@@ -272,26 +269,23 @@
     }
 
     msg(M_INFO, "%s dns servers %s using service", ip_proto_name, (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
-static bool
+static void
 do_wins_service(bool add, const struct tuntap *tt)
 {
-    bool ret = false;
     ack_message_t ack;
     struct gc_arena gc = gc_new();
     HANDLE pipe = tt->options.msg_channel;
-    int len = tt->options.wins_len;
-    int addr_len = add ? len : 0;
+    int addr_len = add ? tt->options.wins_len : 0;
 
-    if (addr_len == 0 && add) /* no addresses to add */
+    if (tt->options.wins_len == 0)
     {
-        return true;
+        /* nothing to do */
+        goto out;
     }
 
     wins_cfg_message_t wins = {
@@ -338,11 +332,9 @@
     }
 
     msg(M_INFO, "WINS servers %s using service", (add ? "set" : "deleted"));
-    ret = true;
 
 out:
     gc_free(&gc);
-    return ret;
 }
 
 static bool
@@ -7019,10 +7011,7 @@
             {
                 do_dns_domain_service(false, tt);
             }
-            if (tt->options.dns6_len > 0)
-            {
-                do_dns_service(false, AF_INET6, tt);
-            }
+            do_dns_service(false, AF_INET6, tt);
             delete_route_connected_v6_net(tt);
             do_address_service(false, AF_INET6, tt);
         }

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/482?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I21a36d24f8e213c780f55acbe3e4df555c93542a
Gerrit-Change-Number: 482
Gerrit-PatchSet: 3
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: d12fk <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged